#include "stdafx.h"
#include "MyDef.h"
#include "CDevice.h"
#include "CMain.h"
#include "CTexture.h"
#include "CSprite.h"

void CSprite::SetPos(float _x, float _y, float _z)
{
	m_World._41 = _x;
	m_World._42 = _y;
	m_World._43 = _z;
}

void CSprite::SetPos(D3DXVECTOR3 _Pos)
{
	m_World._41 = _Pos.x;
	m_World._42 = _Pos.y;
	m_World._43 = _Pos.z;
}

void CSprite::AddPos(float _x, float _y, float _z)
{
	m_World._41 += _x;
	m_World._42 += _y;
	m_World._43 += _z;
}

void CSprite::AddPos(D3DXVECTOR3 _Pos)
{
	m_World._41 += _Pos.x;
	m_World._42 += _Pos.y;
	m_World._43 += _Pos.z;
}

void CSprite::SetRotate(float _Ang)
{
	float x = m_World._41, y = m_World._42, z = m_World._43;
	D3DXMatrixRotationZ(&m_World, D3DXToRadian(_Ang));
	m_World._41 = x;
	m_World._42 = y;
	m_World._43 = z;
}

//void CSprite::AddRotate(float _Ang)
//{
//	D3DXMATRIX Rotate;
//	D3DXMatrixRotationZ(&Rotate, D3DXToRadian(_Ang));
//	m_World = Rotate * m_World;
//}
//
//void CSprite::SetScal(float _x, float _y, float _z)
//{
//	D3DXMATRIX Scal;
//	D3DXMatrixIdentity(&Scal);
//	Scal._11 = _x;
//	Scal._22 = _y;
//	Scal._33 = _z;
//	m_World = Scal*m_World;
//}

void CSprite::Draw(  LPDIRECT3DTEXTURE9 _pTex, float _Width, float _Height )
{
	RECT rc = { 0, 0, (LONG)_Width, (LONG)_Height };
	SPRITE->Draw( _pTex, &rc, &D3DXVECTOR3(_Width/2, _Height/2, 0), NULL, 0xffffffff);
	SPRITE->SetTransform(&m_World);
}

void CSprite::Draw( LPDIRECT3DTEXTURE9 _pTex, float _Width, float _Height, int _AnimeX, int _AnimeY )
{
	RECT rc = { (LONG)_Width*_AnimeX, (LONG)_Height*_AnimeY, (LONG)_Width*_AnimeX + (LONG)_Width, (LONG)_Height*_AnimeY + (LONG)_Height };
	SPRITE->Draw( _pTex, &rc, &D3DXVECTOR3(_Width/2, _Height/2, 0), NULL, 0xffffffff);
	SPRITE->SetTransform(&m_World);
}

void CSprite::Draw( LPDIRECT3DTEXTURE9 _pTex, float _Width, float _Height, D3DXVECTOR3 _Center )
{
	RECT rc = { 0, 0, (LONG)_Width, (LONG)_Height };
	SPRITE->Draw( _pTex, &rc, &_Center, NULL, 0xffffffff);
	SPRITE->SetTransform(&m_World);
}

void CSprite::Draw( LPDIRECT3DTEXTURE9 _pTex, float _Width, float _Height, D3DXVECTOR3 _Center, int _AnimeX, int _AnimeY )
{
	RECT rc = { (LONG)_Width*_AnimeX, (LONG)_Height*_AnimeY, (LONG)_Width*_AnimeX + (LONG)_Width, (LONG)_Height*_AnimeY + (LONG)_Height };
	SPRITE->Draw( _pTex, &rc, &_Center, NULL, 0xffffffff);
	SPRITE->SetTransform(&m_World);
}